package com.oop

/**
 * @description:
 * @author: marshal
 * @date: 2021-08-09 5:36 PM
 */
class Rational(n: Int, d: Int) {
  require(d != 0)
  val number: Int = n
  val denom: Int = d

  override def toString: String = number + "/" + denom

  def add(that: Rational) = new Rational(number * that.denom + that.number * denom, denom * that.denom)
}
